package com.aurora.calculator

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.aurora.calculator.ui.CalculatorScreen
import com.aurora.calculator.ui.theme.CalculatorTheme

class MainActivity : ComponentActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContent {
            val viewModel = viewModel<CalculatorViewModel>()
            val state = viewModel.state

            CalculatorTheme {
                CalculatorScreen(
                    state = state,
                    modifier = Modifier
                        .fillMaxSize()
                        .background(CalculatorTheme.colors.BackgroundColor)
                        .padding(18.dp),
                    onEvents = viewModel::onEvents
                )
            }
        }
    }
}
